package com.ipay.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ipay.dao.PayChannelDao;
import com.ipay.dao.QRCodeDao;
import com.ipay.entity.BizSequenceType;
import com.ipay.entity.PayChannelEntity;
import com.ipay.service.PayChannelService;



@Transactional
@Service("payChannelService")
public class PayChannelServiceImpl implements PayChannelService {
	@Autowired
	private PayChannelDao payChannelDao;
	@Autowired
	private QRCodeDao qRCodeDao;

	@Override
	public PayChannelEntity queryObject(String id) {
		return payChannelDao.queryObject(id);
	}

	@Override
	public List<PayChannelEntity> queryList(Map<String, Object> map) {
		return payChannelDao.queryList(map);
	}

	@Override
	public int queryTotal(Map<String, Object> map) {
		return payChannelDao.queryTotal(map);
	}

	@Override
	public void save(PayChannelEntity payChannel) {
		payChannel.setPayChannelId(DefaultSequenceManager.get().next(BizSequenceType.PAYCHANNELID));
		
		//根据商户号修改系统默认二维码状态为未删除
		qRCodeDao.updateByMerchantNo(payChannel.getMerchantNo());
		
		payChannelDao.save(payChannel);                          
	}

	@Override
	public int update(PayChannelEntity payChannel) {
		return payChannelDao.update(payChannel);
		
	}

	@Override
	public int deleteBatch(String[] ids) {
		return payChannelDao.deleteBatch(ids);
	}

	@Override
	public PayChannelEntity queryInfoByParam(Map<String, Object> map) {
		return payChannelDao.queryInfoByParam(map);
	}
	@Override
	public PayChannelEntity queryPayBymerchantNo(Map<String, Object> map) {
		return payChannelDao.queryPayBymerchantNo(map);
	}

}
